﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NsfcSurvey.Web.BzService;
using NsfcSurvey.Web.Helper;

namespace NsfcSurvey.Web
{
    public partial class View : System.Web.UI.Page
    {
        DataService dataService = new DataService();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            gvData.DataSource = dataService.GetAllAnswers();
            gvData.DataBind();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

            List<Department> departments = dataService.GetAll();
            StringBuilder sb = new StringBuilder();
            foreach (Department department in departments)
            {
                sb.Append("\"" + department.Name + "\",\r");
            }
            ds.Text = sb.ToString();

        }

        protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            GridViewHelper.AddRowNumber(e);
        }
    }
}